package com.example.hadoop.rpc.publish;

import com.example.hadoop.rpc.ClientNameNodeProtocol;
import com.example.hadoop.rpc.NameNodeNameSystem;
import com.example.hadoop.rpc.service.ILoginService;
import com.example.hadoop.rpc.service.impl.LoginServiceImpl;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.ipc.RPC;

import java.io.IOException;

/**
 * Created with IntelliJ IDEA.
 *
 * @Auther: Brian
 * @Date: 2020/04/19/21:03
 * @Description: 将Service通过Hadoop的RPC框架发布出去
 */
public class ServicePublish {

    public static void main(String[] args) throws Exception {
        RPC.Builder builder = new RPC.Builder(new Configuration());
        builder.setBindAddress("localhost").setPort(8888).setProtocol(ClientNameNodeProtocol.class).setInstance(new NameNodeNameSystem());
        RPC.Server server = builder.build();
        
        server.addProtocol(RPC.RpcKind.RPC_WRITABLE, ILoginService.class, new LoginServiceImpl());
        server.start();
    }
}
